import React from 'react'

export default function CountBar({value,onValueChange}) {
    const changeValue=(ev)=>{
        onValueChange(ev.target.value)
    }
    // 减
  const reduce = ()=>{
    onValueChange(value - 1);
  };

  // 加
  const add = ()=>{
    onValueChange(value + 1);

  };
    return (
        <div className='count-bar'>
            <span className={value<=1?'disable':''} onClick={reduce}>-</span>
            <input type="text" value={value} onChange={changeValue}/>
            <span onClick={add}>+</span>
        </div>
    )
}
